package com.example.xungeng2.controller;

import com.example.xungeng2.common.Result;
import com.example.xungeng2.pojo.Fx;
import com.example.xungeng2.service.FXService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/fx")
public class FxController {

    @Autowired
    private FXService fxService;


    @PostMapping("insert")
    public Result insertFx(@RequestBody Fx fx){
        System.out.println(fx);
        boolean save = fxService.save(fx);
        if(save){
            return Result.ok("添加成功");
        }else {
            return Result.fail("添加失败");
        }
    }

    @GetMapping("/selectAll")
    public Result selectAlll(){
        List<Fx> list = fxService.selectAllFx();
        System.out.println(list);
        return Result.ok(list);
    }
}
